/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.geaSV.busquedas;

import com.geaSV.conexiones.conectarBD;
import com.geaSV.entities.ProveedorE;
import com.geaSV.entities.usuarioE;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author vash
 */
public class busquedaProveedor {
    private Connection conx = null;
    private Statement sttm;
    private ResultSet rs;
    
    public List<ProveedorE> buscarDatosProveedor() throws SQLException{
     List <ProveedorE> lst=new ArrayList<ProveedorE> (0);
    try{
        conx = conectarBD.conectar();
        sttm = conx.createStatement();
        rs = sttm.executeQuery("SELECT * FROM proveedor");
        while(rs.next()){
            ProveedorE e= new ProveedorE();
            e.setId(rs.getInt("id"));
            e.setNombre(rs.getString("nombre"));
            e.setGiro(rs.getString("giro"));
            e.setRazonSocial(rs.getString("razonSocial"));
            e.setNit(rs.getString("nit"));
            e.setNrc(rs.getString("nrc"));
            e.setDireccion(rs.getString("direccion"));
            e.setWeb(rs.getString("paginaWeb"));
            e.setEmail(rs.getString("email"));
            e.setContactoP(rs.getString("personaContacto"));
            e.setTelefono(rs.getString("telefono"));
            e.setTipoContribuyente(rs.getString("tipoContribuyente"));
            lst.add(e);
        }
        
    }catch(Exception e){

        System.out.println("esto paso"+e.getMessage());
      
    }finally{
        rs.close();
        sttm.close();
        conx.close();
        return lst; 
    }
    }
    public ProveedorE buscarDatosProveedor(String id) throws SQLException{
    ProveedorE e=new ProveedorE();
    try{
        conx = conectarBD.conectar();
        sttm = conx.createStatement();
        rs = sttm.executeQuery("SELECT * FROM proveedor");
        while(rs.next()){
            e.setId(rs.getInt("id"));
            e.setNombre(rs.getString("nombre"));
            e.setGiro(rs.getString("giro"));
            e.setRazonSocial(rs.getString("razonSocial"));
            e.setNit(rs.getString("nit"));
            e.setNrc(rs.getString("nrc"));
            e.setDireccion(rs.getString("direccion"));
            e.setWeb(rs.getString("paginaWeb"));
            e.setEmail(rs.getString("email"));
            e.setContactoP(rs.getString("personaContacto"));
            e.setTelefono(rs.getString("telefono"));
            e.setTipoContribuyente(rs.getString("tipoContribuyente"));
        }
        
    }catch(Exception s){

        System.out.println("esto paso"+s.getMessage());
      
    }finally{
        rs.close();
        sttm.close();
        conx.close();
        return e; 
    }
    }
    
}
